package com.ai.zuochengyun.phase01.class02;

public class Code01_ExchangeNumWithoutExtraVariable {
    public static void main(String[] args) {
        int[] arr = new int[2];

    }

    private static void exchange(int[] arr) {
        int a = arr[0];
        int b = arr[1];
        a = a ^ b;
        b = a ^ b; // a ^ b ^ b  ==>  a
        a = a ^ b; // a ^ b ^ a  ==>  b
        arr[0] = b;
        arr[1] = a;
    }
}
